﻿
using MediatR;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using Warehouse.Api.Read.AGCation.Command;
using Warehouse.Api.Read.Dtos;
using Warehouse.Domian;
using Warehouse.Domian.Model;
using Warehouse.ErrorCode;

namespace Warehouse.Api.Read.Controllers
{
    [Route("api/[controller]/[action]")]
    [ApiController]
    public class InventoryController : ControllerBase
    {
        public readonly IMediator mediator;
        public readonly ILogger<InventoryController> logger;

        public InventoryController(IMediator mediator, ILogger<InventoryController> logger)
        {
            this.mediator = mediator;
            this.logger = logger;
        }

        /// <summary>
        /// 获取库存盘点信息的列表
        /// </summary>
        /// <param name="request"></param>
        /// <param name="cancellationToken"></param>
        /// <returns></returns>
        [HttpGet]
        public async Task<ApiPaging<InventoryDto>> GetInventory([FromQuery]GetInventoryCommand request)
        {
            return await mediator.Send(request);
        }
        /// <summary>
        /// 盘点仓库类型列表
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        [HttpGet]
        public async Task<ApiResult<List<WarehouseTypeModel>>> GetType([FromQuery]GetInventoryTypeCommand request)
        {
            return await mediator.Send(request);
        }
        /// <summary>
        /// 获取仓库的名称
        /// </summary>
        /// <param name="request"></param>
        /// <param name="cancellationToken"></param>
        /// <returns></returns>
        [HttpGet]
        public async Task<ApiResult<List<InventoryModel>>> GetWarehouse([FromQuery]GetWarehouseCommand request)
        {
            return await mediator.Send(request);
        }
        /// <summary>
        /// 获取库存信息列表(添加)
        /// </summary>
        /// <param name="request"></param>
        /// <param name="cancellationToken"></param>
        /// <returns></returns>
        [HttpGet]
        public async Task<ApiPaging<BasicinformatioDto>> GetBasicinformatio([FromQuery]BasicinformatioCommand request)

        {
            return await mediator.Send(request);
        }
        /// <summary>
        /// 显示结果信息的列表
        /// </summary>
        /// <param name="request"></param>
        /// <param name="cancellationToken"></param>
        /// <returns></returns>
        [HttpGet]
        public async Task<ApiResult<List<ResultModel>>> GetResult([FromQuery]GetResultCommand request)
        {
            return await mediator.Send(request);
        }
        /// <summary>
        /// 统计报错信息
        /// </summary>
        /// <param name="request"></param>
        /// <param name="cancellationToken"></param>
        /// <returns></returns>
        [HttpGet]
        public async Task<ApiPaging<InboundDto>> GetInbound([FromQuery]InboundCommand request)
        {
            return await mediator.Send(request);
        }
        /// <summary>
        /// 统计出库的信息
        /// </summary>
        /// <param name="request"></param>
        /// <param name="cancellationToken"></param>
        /// <returns></returns>
        [HttpGet]
        public async Task<ApiResult<List<Stocking>>> GetStocking([FromQuery]StockoutCommand request)
        {
            return await mediator.Send(request);
        }
        /// <summary>
        /// 入库的统计数据
        /// </summary>
        /// <param name="request"></param>
        /// <param name="cancellationToken"></param>
        /// <returns></returns>
        /// <exception cref="NotImplementedException"></exception>
        [HttpGet]
        public async Task<ApiResult<List<Stocking>>> GetAllocate([FromQuery]StockinCommand request)
        {
            return await mediator.Send(request);
        }
        /// <summary>
        /// 调拨的查询
        /// </summary>
        /// <param name="request"></param>
        /// <param name="cancellationToken"></param>
        /// <returns></returns>
        [HttpGet]
        public async Task<ApiPaging<TransferDto>> GetTransfer([FromQuery]AllCommand request)
        {
            return await mediator.Send(request);
        }
        /// <summary>
        /// 出库记录查询列表
        /// </summary>
        /// <param name="request"></param>
        /// <param name="cancellationToken"></param>
        /// <returns></returns>
        [HttpGet]
        public async Task<ApiResult<List<OutboundDto>>> GetOutbound([FromQuery]OutboundCommand request)
        {
            return await mediator.Send(request);
        }
        /// <summary>
        /// 出库的统计数据
        /// </summary>
        /// <param name="request"></param>
        /// <param name="cancellationToken"></param>
        /// <returns></returns>
        [HttpGet]
        public async Task<ApiResult<List<OutboundDto>>> Getchuku([FromQuery]GetStockinCommand request)
        {
            return await mediator.Send(request);
        }
    }
}
